package com.example.pro1.controller.zhao;

import com.example.pro1.entity.zhao.Product;
import com.example.pro1.service.zhao.table.ProductService;
import com.example.pro1.valu.R;
import com.example.pro1.valu.Standard;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin//开放前端跨域访问
@Api(tags = "商品管理")
@RestController
@RequestMapping("/api/product")

public class ProductController {

    @Resource
    private ProductService productService;

    @ApiOperation("测试接口")
    @GetMapping("/test")
    public Standard test()
    {
        return R.ok().data("name","包子好吃");
    }

    @GetMapping("/list")
    public Standard list()
    {
        List<Product> list=productService.list();
        return R.ok().data("productList",list);
    }
}
